<?php

class FightControl extends Control {

	public function gofight()
	{
        $uid = self::isauth();
        if (!$uid) return $this->out_error(ERR303);

		$tuid = intval($_POST['tuid']);

        $ret = modcall("fight", "gofight", array($uid, $tuid));
        if ($ret['ecode']) return $this->out_error($ret['ecode']);
        else return $this->out_result(&$ret['ret']);
    }

	public function getsuccluck()
	{
        $uid = self::isauth();
        if (!$uid) return $this->out_error(ERR303);

		$tuid = intval($_POST['tuid']);
		$tuid = intval($_GET['tuid']);

        $ret = modcall("fight", "getsuccluck", array($uid, $tuid));
        if ($ret['ecode']) return $this->out_error($ret['ecode']);
        else return $this->out_result(&$ret['ret']);
    }

	public function succluck()
	{
        $uid = self::isauth();
        if (!$uid) return $this->out_error(ERR303);

		$tuid = intval($_POST['tuid']);
		$tuid = intval($_GET['tuid']);
		$drops = trim($_POST['drops']);
		$drops = trim($_GET['drops']);

		$drops = $drops ? explode(",", $drops) : array();
		$drops = $drops ? $drops : array();

        $ret = modcall("fight", "succluck", array($uid, $tuid, $drops));
        if ($ret['ecode']) return $this->out_error($ret['ecode']);
        else return $this->out_result(&$ret['ret']);
    }

	public function testfight()
	{
        $uid = self::isauth();
        if (!$uid) return $this->out_error(ERR303);

		$tuid = intval($_POST['tuid']);
		$tuid = intval($_GET['tuid']);

        $ret = modcall("fight", "testfight", array($uid, $tuid));
        if ($ret['ecode']) return $this->out_error($ret['ecode']);
        else return $this->out_result(&$ret['ret']);
    }
}

?>